package com.mrjy.maintain.bo;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.mrjy.common.entity.ApplyLectureInfo;
import com.mrjy.maintain.dao.IApplyLectureInfoDao;

@Service("ApplyLectureInfoBo")
public class ApplyLectureInfoBo implements IApplyLectureInfoBo {
	@Resource
	private IApplyLectureInfoDao applyLectureInfoDao;



	@Override
	public Map<String, Object> queryPageApplyLectureInfo(ApplyLectureInfo lectureInfo) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", applyLectureInfoDao.countApplyLectureInfo(lectureInfo));
		List<ApplyLectureInfo> list = applyLectureInfoDao.queryPageApplyLectureInfo(lectureInfo);	
		map.put("rows",list);
		return map;
	}
	

	

	@Override
	public int insert(ApplyLectureInfo  lectureInfo) {
		// TODO Auto-generated method stub
		lectureInfo.setUnitName(lectureInfo.getUnitName());
		lectureInfo.setContactsName(lectureInfo.getContactsName());
		lectureInfo.setProvince(lectureInfo.getProvince());
		lectureInfo.setCity(lectureInfo.getCity());
		lectureInfo.setCountry(lectureInfo.getCountry());
		lectureInfo.setDisableFlag(0);
		lectureInfo.setApplyTime(new Date().getTime());
		return applyLectureInfoDao.insert(lectureInfo);
	}

	@Override
	public ApplyLectureInfo queryById(int id) {
		// TODO Auto-generated method stub
		return applyLectureInfoDao.queryById(id);
	}

	@Override
	public int updateById(ApplyLectureInfo  lectureInfo) {
		// TODO Auto-generated method stub
		return applyLectureInfoDao.updateById(lectureInfo);
	}

	@Override
	public int deleteByIds(int[] ids) {
		// TODO Auto-generated method stub
		try{
			return applyLectureInfoDao.deleteByIds(ids);
		}catch(DataAccessException  e){
			return 0;
		}
	}

	@Override
	public int updateDisableFlag(ApplyLectureInfo  lectureInfo) {
		// TODO Auto-generated method stub
		return applyLectureInfoDao.updateDisableFlag(lectureInfo);
	}

}
